package com.darrenchan.leetcode;

/**
 * @Desc
 * @Author chenchi03
 * @CreateTime 2020-04-22 21:40
 */
public class QLint373 {
    public void partitionArray(int[] nums) {
        if(nums == null || nums.length == 0) {
            return;
        }

        int i = 0, j = nums.length - 1;
        while (i <= j) {
            while (i <= j && nums[i] % 2 == 1) {
                i++;
            }
            while (i <= j && nums[j] % 2 == 0) {
                j--;
            }
            if(i <= j) {
                int temp = nums[i];
                nums[i] = nums[j];
                nums[j] = temp;

                i++;
                j--;
            }
        }
    }
}
